PROJECTENGRAM

[HO] 18 - MST

MST

Tags: #◇Computer Science #◇CCDSALG #◇MST #◇Conceptual #◇M6


◇Overview

A Spanning Tree is an acyclic graph that connects all the vertices of a connected graph. A Minimum Spanning Tree (MST) is a spanning tree whose total edge weight is minimized. The document introduces two greedy algorithms for finding the MST: Prim's algorithm, which grows the tree from an arbitrary root vertex, and Kruskal's algorithm.

◇Important Formulas

MST Definition:
For a connected, undirected weighted graph G=(V,E,w)G = (V, E, w), find an acyclic subgraph T⊆ET \subseteq E connecting all vertices VV such that:
w(T)=∑(u,v)∈Tw(u,v)is minimized.w(T) = \sum_{(u, v) \in T} w(u, v) \quad \text{is minimized.}

  • A spanning tree for ∣V∣|V| vertices always contains exactly ∣V∣−1|V| - 1 edges.

Cut Property (Theoretical Foundation):
Let (S,V∖S)(S, V \setminus S) be any cut that respects A⊆TA \subseteq T. If (u,v)(u, v) is a light edge crossing (S,V∖S)(S, V \setminus S), then (u,v)(u, v) is safe for AA.

Algorithmic Complexities:

AlgorithmStrategyData StructureTime ComplexityPreferred Graph Type
Kruskal'sEdge-centric (Global sort)Disjoint-Set / Union-FindO(Elog⁡E)=O(Elog⁡V)O(E \log E) = O(E \log V)Sparse graphs (E≪V2E \ll V^2)
Prim'sVertex-centric (Grows single tree)Min-Priority QueueO(Elog⁡V)O(E \log V) (Binary Heap) / O(E+Vlog⁡V)O(E + V \log V) (Fibonacci Heap)Dense graphs (E≈V2E \approx V^2)

◇Theoretical Framework: MST Construction Paradigms

Kruskal's Cycle-Detection Execution Pipeline (Union-Find)

◇Worked Examples

  1. Kruskal's Step-by-Step Trace:
    • Graph with vertices {A,B,C,D}\{A, B, C, D\} and sorted edges: (A,B):1(A, B): 1, (B,C):2(B, C): 2, (A,C):3(A, C): 3, (C,D):4(C, D): 4, (B,D):5(B, D): 5.
    • Pick (A,B)(A, B) (weight 1): Sets are {A},{B}\{A\}, \{B\}. A≠B  ⟹  A \neq B \implies Add (A,B)(A, B). Union: {A,B}\{A, B\}.
    • Pick (B,C)(B, C) (weight 2): Set of BB is {A,B}\{A, B\}, set of CC is {C}\{C\}. Distinct   ⟹  \implies Add (B,C)(B, C). Union: {A,B,C}\{A, B, C\}.
    • Pick (A,C)(A, C) (weight 3): Set of AA is {A,B,C}\{A, B, C\}, set of CC is {A,B,C}\{A, B, C\}. Same set! Reject to avoid cycle A−B−C−AA-B-C-A.
    • Pick (C,D)(C, D) (weight 4): Set of CC is {A,B,C}\{A, B, C\}, set of DD is {D}\{D\}. Distinct   ⟹  \implies Add (C,D)(C, D). Union: {A,B,C,D}\{A, B, C, D\}.
    • ∣V∣−1=3|V|-1 = 3 edges chosen. Total MST Weight: 1+2+4=71 + 2 + 4 = 7.

◇References & Navigation